Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Sep 12, 2025

Summary

This PR adds support for the Gemini provider for image generation, allowing users to choose between OpenRouter and Gemini for generating images.

Changes

Features

  • Provider Selection: Added dropdown in settings to switch between OpenRouter and Gemini
  • Gemini Integration: Implemented image generation supporting text-to-image and image-to-image (editing)
  • Model Support: Using the gemini-2.0-flash-exp model

Architecture

  • Created centralized image generation models configuration in packages/types
  • Updated generateImageTool to route requests to appropriate provider

UI/UX

  • Dynamic API key inputs based on selected provider
  • Model dropdown updates based on provider selection
  • Clear warning messages when API keys are missing

Internationalization

  • Translated all new UI strings across 18 supported languages

Settings Management

  • Fixed persistence for image generation configuration
  • Added proper state management for provider, API keys, and model selection

Testing

  • TypeScript compilation passes
  • ESLint checks pass
  • Settings persist between sessions
  • Both providers work correctly when configured

Breaking Changes

None - maintains full backward compatibility with existing OpenRouter integration

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Sep 12, 2025
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and found some issues that need attention. The implementation looks solid overall, but there are critical issues with test coverage and model configuration that should be addressed.

Critical Issues:

  1. Missing test coverage - The existing test file only tests OpenRouter but doesn't include any tests for the new Gemini provider functionality.
  2. Model ID mismatch - The PR description mentions using gemini-2.0-flash-exp but the code uses gemini-2.5-flash-image-preview.

// For Gemini, we can use the existing Gemini API key from the provider settings
// Check for a dedicated image generation API key first, then fall back to the provider's API key
apiKey =
state?.geminiImageApiKey ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback to the main Gemini API key is a nice touch for user convenience. However, could we add a comment here explaining this fallback behavior so future maintainers understand the logic?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 12, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Sep 12, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 12, 2025
- Create centralized image generation models configuration in types package
- Implement generateImage() method in Gemini provider for text-to-image and image-to-image
- Add provider dropdown in UI settings to switch between OpenRouter and Gemini
- Update generateImageTool to route requests to appropriate provider
- Add settings persistence for Gemini API key and model selection
- Translate all new UI strings across 18 supported languages
- Fix settings state management to properly handle new image generation settings
Address PR review feedback by using the correct Content type from the
Gemini SDK for the contents array in generateImage method
The provider state was being updated inside the effect while also being
included in the dependency array, which could cause unnecessary re-renders
or potential infinite loops. Fixed by using a local newProvider variable
to calculate the correct selected model before updating state.
@hannesrudolph hannesrudolph force-pushed the feat/gemini-image-generation branch from d7a20fd to 71c2bcf Compare October 20, 2025 18:08
@roomote
Copy link

roomote bot commented Oct 20, 2025

Review Summary

All previously identified issues have been addressed or acknowledged:

Code Review Complete - No additional issues found. The implementation follows existing patterns, maintains type safety, and integrates cleanly with the codebase architecture.

@daniel-lxs daniel-lxs closed this Oct 31, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 31, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants